function showsolution(node, elem, u)

dim = size(node, 2);
data = [node, u];
if ~iscell(elem) && dim==2
    patch('Faces', elem, 'Vertices', data, 'Facecolor', 'interp', 'CData', u/max(abs(u))) ;
end
if iscell(elem)
    max_n_vertices = max(cellfun(@length, elem));
    padding_func = @(vertex_ind) [vertex_ind, NaN(1, max_n_vertices - length(vertex_ind))];
    tpad = cellfun(padding_func, elem, 'UniformOutput', false);
    tpad = vertcat(tpad{:});
    patch('Faces', tpad, 'Vertices', data, 'FaceColor', 'interp', 'CData', u/max(abs(u)));
end
axis('square');
sh = 0;
xlim([min(node(:,1)) - sh, max(node(:,1)) + sh])
ylim([min(node(:,2)) - sh, max(node(:,2)) + sh])
zlim([min(u) - sh , max(u) + sh])
xlabel('x');
ylabel('y');
zlabel('u');
view(3);
grid on;

end